package keeto.com.vn.bms.network.task;

import java.io.IOException;

import org.apache.http.client.ClientProtocolException;
import org.json.JSONException;

import keeto.com.vn.bms.config.IBMSCore;
import keeto.com.vn.bms.network.request.GetuserLogoutResquest;
import keeto.com.vn.bms.network.response.GetuserLogoutResponse;
import keeto.com.vn.bms.utils.BMSListener;

public class TaskLogout extends AbstractTask{

	private String authKey;
	
	public TaskLogout(BMSListener listener, IBMSCore core,String Auth) {
		super(listener, core);
		// TODO Auto-generated constructor stub
		this.authKey= Auth;
	}

	@Override
	public void run() throws ClientProtocolException, JSONException,
			IOException {
		// TODO Auto-generated method stub
		GetuserLogoutResquest resquest = new GetuserLogoutResquest();
		resquest.setmAuthKey(authKey);
		GetuserLogoutResponse response= protocol.getLogout(resquest);
		for (BMSListener mlistener : listener){
			mlistener.finishLogout(response.getReturnCode(), response.getResultMsg());
		}
	}

	@Override
	public void timeoutCallback() {
		// TODO Auto-generated method stub
		for (BMSListener mlistener : listener){
			mlistener.finishLogout(protocol.STATUS_CODE_GENERIC_FAIL_CONECTTION, null);
		}
	}

}
